class Singleton:
    _instance = None  # 类变量来保存实例

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:  # 如果实例不存在，则创建新实例
            cls._instance = object.__new__(cls)
        return cls._instance  # 返回实例

    def __init__(self, name):
        if not hasattr(self, 'name'):  # 如果实例没有name属性，则进行初始化
            self.name = name


if __name__ == "__main__":
    a = Singleton("name1")
    b = Singleton("name2")
    print(id(a), id(b))
    print(a.name, b.name)